<?PHP
	function get_client_ip(){
		if (isset($_SERVER['HTTP_CLIENT_IP']) && !empty($_SERVER['HTTP_CLIENT_IP'])){
			return $_SERVER['HTTP_CLIENT_IP'];
		}
		if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && !empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
			return strtok($_SERVER['HTTP_X_FORWARDED_FOR'], ',');
		}
		if (isset($_SERVER['HTTP_PROXY_USER']) && !empty($_SERVER['HTTP_PROXY_USER'])){
	  		return $_SERVER['HTTP_PROXY_USER'];
		}
		if (isset($_SERVER['REMOTE_ADDR']) && !empty($_SERVER['REMOTE_ADDR'])){
			return $_SERVER['REMOTE_ADDR'];
		}else{
			return "0.0.0.0";
		}
	}
	//创建数组
	$act = $_GET['act'];
	$ip = get_client_ip();
	if($act == 'query'){
		$jsonArr = array(
			'flag' => 'SUCCESS',
			'msg' => '查询成功',
			'data' => array(
				array(
					  'ip' => $ip, //获取登录IP, 
					  "id"=> array('1','2','3'), 
					  "sitename"=>'web编程站', 
					  "siteurl"=>'http://www.eb163.com'
				),
			),
		);
	}else{
		$jsonArr = array(
			'flag' => 'ERROR',
			'msg' => '查询失败',
			'data' => array(),
		);
	}
	echo json_encode($jsonArr);
?>